﻿package Component
{
	import Map.Spawn;
	import Map.Zone;

	public class Duel extends Map
	{
		private var zone:Zone;

		public function Duel()
		{
		}

		public override function initialize(context:Context)
		{
			super.initialize(context);
			// register spawns
			builders.push(spawn1);
			attach(spawn1.avatar);
			spawn1.avatar.colorize(0);
			builders.push(spawn2);
			attach(spawn2.avatar);
			spawn2.avatar.colorize(1);

			// attach avatars to players
			context.match.getPlayer(0).avatar = spawn1.avatar;
			context.match.getPlayer(1).avatar = spawn2.avatar;

			zone = new Zone(context,3);
			builders.push(zone);

			// attach all blocks to zone
			var block:BonusBlock;
			for (var x:int = 1; x < 12; x++)
			{
				for (var y:int = 1; y < 8; y++)
				{
					if ( (x%2 == 1) || (y%2 == 1) )
					{
						if (((x == 1) && (y < 3)) || ((y == 1) && (x < 3)))
						{
							continue;
						}
						if (((x == 11) && (y > 5)) || ((y == 7) && (x > 9)))
						{
							continue;
						}
						attach(zone.createBonusBlock(x,y));
					}
				}

			}
			zone.initialize();
		}
	}

}